package com.ctosb.classviewer.clazz.attr;

import com.ctosb.classviewer.ClassReader;
import com.ctosb.classviewer.clazz.cp.CONSTANT_Class_info;
import com.ctosb.classviewer.clazz.cp.Cp_info;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ConstantValue_attribute extends Attribute_info {

    private short constantvalue_index;

    @Override
    protected void doParse(ClassReader classReader) {
        this.constantvalue_index = classReader.readShort();
    }

    /**
     * 获取常量值信息
     * @Author alan
     * @Date 2020/12/16 12:16 上午
     * @return
     */
    public Cp_info getConstantvalue() {
        return getClassFile().getConstant_pool()[constantvalue_index];
    }
}
